const list = [1, 2, 3, 4, 5, 1, 3, 3, 1, 2, 3, 56, 12]
function findMostFrequentValue(arr) {
    const counts = {};
    let maxCount = 0;
    let mostFrequentValue;

    for (const value of arr) {
        if (counts[value]) {
            counts[value]++;
        } else {
            counts[value] = 1;
        }

        if (counts[value] > maxCount) {
            maxCount = counts[value];
            mostFrequentValue = value;
        }
    }

    return { value: mostFrequentValue, count: maxCount };
}